package com.starblink.product.productweb.ui

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.apollographql.apollo3.api.Optional
import com.starblink.android.basic.base.BaseViewModel
import com.starblink.android.basic.network.base.SkGqlClient
import com.starblink.android.basic.user.UserDataCenter
import com.starblink.rocketreserver.FetchProductDetailByIdQuery
import com.starblink.rocketreserver.fragment.ProductF
import kotlinx.coroutines.launch

class ProductWebVM : BaseViewModel() {
    val productInfo= MutableLiveData<ProductF>()//品牌信息
    fun reqProductDetail(productId:String){
        viewModelScope.launch {
            val response = SkGqlClient.skQuery(
                FetchProductDetailByIdQuery(
                    productId = Optional.present(productId),
                ),
            )
            if (response?.data != null && response.data!!.fetchProductDetailById != null) {
                val productF = response.data!!.fetchProductDetailById!!.productF
                productInfo.value=productF
            }
        }
    }
}